﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tools.Api.Cache {

    /// <summary>
    ///     Adatper模式
    /// </summary>

    public interface ICacheStorage {

        /// <summary>
        /// 移除
        /// </summary>
        /// <param name="key"></param>
        void Remove(string key);

        /// <summary>
        /// 存储
        /// </summary>
        /// <param name="key"></param>
        /// <param name="data"></param>
        void Store(string key, object data);

        /// <summary>
        /// 读取
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        T Retrieve<T>(string key);

        /// <summary>
        /// 变更与拉取
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="method"></param>
        /// <returns></returns>
        T Pull<T>(string key, Func<T> method);
    }
}
